{% extends 'base/base1.html' %}

{% block title %}{% if object %}编辑订单{% else %}添加订单{% endif %}{% endblock %}

{% block main %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h4>{% if object %}编辑订单{% else %}添加订单{% endif %}</h4>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>用户</label>
                                    {{ form.user }}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>商品</label>
                                    {{ form.product }}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>单价</label>
                                    {{ form.price }}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>数量</label>
                                    {{ form.quantity }}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>订单状态</label>
                                    {{ form.status }}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>收货地址</label>
                                    {{ form.shipping_address }}
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary">保存</button>
                            <a href="{% url 'main:order_list' %}" class="btn btn-secondary">取消</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}